/*
 * TestListContacts Class
 */

package tests;
import models.*;

/**
 *
 * @author tlnguyen
 */
public class TestListContacts {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // creating 5 contacts
        Contact c1 = new Contact("C1", "A1");
        Contact c2 = new Contact("C2", "A2");
        Contact c3 = new Contact("C3", "A3");
        Contact c4 = new Contact("C4", "A4");
        Contact c5 = new Contact("C5", "A5");

        // creating the contact list
        ListContacts listContacts = new ListContacts();
        // showing the empty list
        System.out.println("Creating a list...");
        System.out.println("All contact(s): " + listContacts.size());

        // adding all the 5 contacts into the list
       System.out.println("Adding contacts...");
       listContacts.addContact(c1);
       listContacts.addContact(c2);
       listContacts.addContact(c3);
       listContacts.addContact(c4);
       listContacts.addContact(c5);

       // showing the the list of 5 contacts
       System.out.println("All contact(s): " + listContacts.size());
       System.out.println(listContacts.toString());

       // removing the 4th contact, c4 object passed in parameter
       System.out.println("Removing c4, c4 object passed in parameter...");
       listContacts.removeContact(c4);
       System.out.println("All contact(s): " + listContacts.size());
       System.out.println(listContacts.toString());  

       // removing the 2nd contact, the 2nd nickname passed in parameter
       System.out.println("Removing c2, the nickname passed in parameter...");
       listContacts.removeContact("C2");
       System.out.println("All contact(s): " + listContacts.size());
       System.out.println(listContacts.toString());

       // searching a contact in the list
       System.out.println("Searching for a contact with the nickname C3...");
       Contact contactFound = listContacts.getContact("C3");
        if (contactFound != null) {
            System.out.println("Contact found: " + contactFound);
        } else {
            System.out.println("Too bad. Not found");
        }
       System.out.println("Searching for a contact with the nickname C2...");
       contactFound = listContacts.getContact("C2");
        if (contactFound != null) {
            System.out.println("Contact found: " + contactFound);
        } else {
            System.out.println("Too bad. Not found");
        }
        System.out.println("Searching for a contact with the address A3...");
        contactFound = listContacts.getContactByAddress("A3");
        if (contactFound != null) {
            System.out.println("Contact found: " + contactFound);
        } else {
            System.out.println("Too bad. Not found");
        }

       // removing all the contacts in the list
       System.out.println("Removing all contacts in the list...");
       listContacts.removeAllContacts();
       System.out.println("All contact(s): " + listContacts.size());
       System.out.println(listContacts.toString());
       listContacts = null;

       System.out.println("---- THE END ----");
    }
}
